<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:a="http://richfaces.org/a4j"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:rg="http://www.ruijie.com.cn/faces/ui"
	xmlns:c="http://java.sun.com/jstl/core"
	template="/layout/contentLayout.xhtml">

	<ui:param name="param_pageTitle"
		value="#{messages.luyuan_crm_menu_order}" />
	<ui:param name="param_navigationUrl"
		value="/luyuan/sale/layout/navigationSale.jsf" />

	<ui:define name="road">
		<span><h:outputLink value="/luyuan/sale/orderListForSale.jsf">我的订单</h:outputLink> &gt;&gt; 新建订单</span>
	</ui:define>

	<!-- content -->
	<ui:define name="content">
		<rg:areaPanel>
			<h:form id="frmAddOrder">
			<rg:titlePanel headerTitle="订单类型">
				<rg:fieldSet >
					<rg:selectOne id="orderType" value="#{addOrderAction.orderType}" required="true"
						label="#{messages.luyuan_crm_sale_order_type}" itemsProvider="#{orderTypeProvider}"/>
					<rg:selectOne id="productType" label="配方类型" value="#{addOrderAction.productType}" 
						itemsProvider="#{productTypeProvider}" converter="#{productTypeConverter}" style="width:100px;">
						<rg:relevant for="orderType" relevantValue="^(FORMULA)$" type="show" />
					</rg:selectOne>
				</rg:fieldSet>
			</rg:titlePanel>
		
			<rg:titlePanel headerTitle="购买客户">
				<rg:fieldSet column="auto">
					<rg:field id="customer" label="姓名或者手机号码" >
						<h:inputText id="customer" value="#{addOrderAction.customer}" converter="#{customerMoblieConverter}">
							<a:support event="onblur" reRender="memberDetail" ajaxSingle="true" eventsQueue="customer"/>
						</h:inputText>
					</rg:field>
					<rich:suggestionbox id="suggestionBoxId" for="customer" tokens=",[]"
	                    suggestionAction="#{customerMoblieProvider.getSuggestionItems}" var="result"
	                    fetchValue="#{result.mobile}" 
	                    minChars="1"   eventsQueue="customer"
	                    nothingLabel="无此客户信息" columnClasses="center"
	                    usingSuggestObjects="true">
	                    <h:column>
	                        <h:outputText value="#{result.name}" />
	                    </h:column>
	                    <h:column>
	                        <h:outputText value="#{result.mobile}" />
	                    </h:column>
                	</rich:suggestionbox>
					
					<h:outputLink value="#" style="padding-left: 5px;line-height: 22px;"
						onclick="UI.instance.showDialog({id:'add', src:'/luyuan/member/addUser.jsf'});" >
						#{messages.luyuan_crm_sale_register_member}
					</h:outputLink>
				</rg:fieldSet>

				<h:panelGroup id="memberDetail">
					<rg:fieldSet column="double" >
	                    <rg:outputText id="name" value="#{addOrderAction.customer.name}" label="#{messages.luyuan_member_name}" />
	                    <rg:outputText id="mobile" value="#{addOrderAction.customer.mobile}" label="#{messages.luyuan_member_mobile}" />
	                    <rg:outputText id="gender"  required="true"  label="姓别" value="#{addOrderAction.customer.gender}" 
	                    	converter="#{genderConverter}"/>
						<rg:outputText id="nativePlace" label="籍贯" value="#{addOrderAction.customer.nativePlace}"/>
	                    <rg:outputText id="address" value="#{addOrderAction.customer.address.getAddress()}" label="#{messages.luyuan_member_addresses}" />
	                    <rg:outputText id="postCode" value="#{addOrderAction.customer.address.postCode}" label="#{messages.luyuan_member_postCode}" />
					</rg:fieldSet>
				</h:panelGroup>
			</rg:titlePanel>

			<div class="panelButton">
					<h:commandButton styleClass="button larger" id="btnAddOrder"
						onclick="if (!jQuery(this).data('submit')) {setTimeout(function() {jQuery('#frmAddOrder\\:btnAddOrder').data('submit',true).click();}, 64);return false;} jQuery(this).data('submit',false);"
						value="#{messages.luyuan_crm_start_order}"
						action="#{addOrderAction.startWizard()}" />
					<h:commandButton styleClass="button larger" immediate="true"
						value="返回" action="/luyuan/sale/orderListForSale.jsf" />
			</div>
			</h:form>
		</rg:areaPanel>
		
		<a:form>
			<a:jsFunction name="reRenderMemberTable"  eventsQueue="customer"/>
		</a:form>
	</ui:define>
</ui:composition>